//////////////////////////////////////////////////////////////////
// MattiseOS Kernel
// Date: 2008
// Author: Matthew Iselin
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//////////////////////////////////////////////////////////////////

#ifndef VMM_H
#define VMM_H

// Includes
#include <core/intrcommon.h>

// Types

// a far pointer (ie, one with a segment and offset)
typedef uint32_t FARPTR;

// Macros

// builds a far pointer
#define MAKE_FAR_POINTER(seg, off)      ((FARPTR) (((uint32_t) (seg) << 16) | (uint16_t) (off)))

// grabs the segment from a far pointer
#define FAR_POINTER_SEG(fp)             (((FARPTR) fp) >> 16)

// grabs the offset from a far pointer
#define FAR_POINTER_OFF(fp)             (((FARPTR) fp) & 0xffff)

// converts a seg:off pair to a linear poiner
#define FAR_POINTER_TO_LINEAR(seg, off) ((void*) ((((uint16_t) (seg)) << 4) + ((uint16_t) (off))))

// Prototypes

// the virtual mode monitor
void kVmm( struct stack_layout* stack );

#endif
